<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>附件管理</title>
	<hdjs />
	
	<css file="__PUBLIC__/Css/mod.base.css" />
	<script type="text/javascript">
		//预览图片
		function view_image(obj) {
			var src = $(obj).attr('src');
			var viewImg = $('#view_img');
			//删除预览图
			if (viewImg.length >= 1) {
				viewImg.remove();
			}
			//鼠标移除时删除预览图
			$(obj).mouseout(function(){
				$('#view_img').remove();
			})
			if (src) {
				var offset = $(obj).offset();
				var _left = 100+offset.left+"px";
				var _top = offset.top-50+"px";
				var html = '<img src="' + src + '" style="border:solid 5px #dcdcdc;position:absolute;z-index:1000;width:300px;left:'+_left+';top:'+_top+';" id="view_img"/>';
				$('body').append(html);
			}
		}
	</script>
</head>
<body>
	
	<div class="wrap">
		<form action="{:U('Attachment/update_del')}" method="post" class='hd-form'>
				<div class="menu_list">
					<ul>
						<li>
							<a href="javascript:;" class="action">
								附件管理
							</a>
							<!-- <a href="javascript:;" class="action">
								更新附件路径
							</a> -->
						</li>
						
					</ul>
				</div>
				<table class="table2">
					<thead>
						<tr>
							<td class="w30">
							<input type="checkbox" class="select_all"/>
							</td>
							<td class="w30">ID</td>
							<td class="w100">预览</td>
							<td >文件名</td>
							<td class="w100">类型</td>
							<td class="w200">路径</td>
							<td class="w100">大小</td>
							<td class="w100">上传时间</td>
							<td class="w50">用户id</td>
							<td class="w180">操作</td>
						</tr>
					</thead>
						<if condition='$data'>
						<foreach name='data' item='v'>
						<tr>
							<td>
							<input type="checkbox" name="id[{$v.id}]" value="{$v.id}"/>
							</td>
							<td>{$v.id}</td>
							<td>
							<img src="{$v.img}" alt="预览大图"  width="50" <if condition='$v["ispic"]'>onmouseover='view_image(this)'</if> />

							</td>
							<td>{$v.name}</td>
							<td>{$v.ext}</td>
							<td>{$v.path}</td>
							<td>{$v.size}</td>
							<td>{$v.time}</td>
							<td>{$v.username}</td>
							<td>
							<a href="javascript:var del='{:U('Attachment/del',array('id'=>$v['id']))}';hd_confirm('确认删除吗？',function(){location.href=del})">
								删除
							</a>
							</td>
						</tr>
						</foreach>
						<else/>
							<tr>
								<td colspan="9">没有找到符合的记录</td>
							</tr>
						</if>
					</table>
				<div class="h60"></div>
		</form>
	</div>
<div class="position-bottom">
	<input type="button" class="hd-cancel" onclick="select_all(1)" value='全选'/>
	<input type="button" class="hd-cancel" onclick="select_all(0)" value='反选'/>
	<input type="button" class="hd-cancel" onclick="update_del()" value="批量删除"/>		
</div>
<script>
//批量删除
function update_del() {
    //信息检测
    if ($("input[type='checkbox']:checked").length == 0) {
        alert('没有信息用于删除');
        return false;
    }
  	$('form').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>
</body>
</html>